// pages/waitpay/waitpay.js
var util=require('../../utils/util.js')
Page({

  /**
   * 页面的初始数据
   */
  data: {
    orderslists:null,
    payid:null,
    time:{},
    times:null,
  },

  // 取消订单
  cancel(){
    let listss = wx.getStorageSync('goodsOrderList').filter((item)=>{
      return item.orderId != this.data.orderslists.orderId     //过滤本商品返回其他商品
    })
    console.log("quxiao",listss)
    wx.setStorageSync('goodsOrderList', listss)
    wx.redirectTo({
      url:"/pages/order/order"
    })
  },


  // 微信支付
  paybox(){
console.log("ssss",this.data.orderslists)
     this.data.orderslists.type=2     //更改类型
     console.log("更改",this.data.orderslists)
     let listss = wx.getStorageSync('goodsOrderList').filter((item)=>{
       return item.orderId != this.data.orderslists.orderId     //过滤本商品返回其他商品
     })
     console.log("lis",listss)
     listss.unshift(this.data.orderslists)
     console.log("苏州",listss)

     wx.setStorageSync('goodsOrderList', listss)
     wx.redirectTo({
      url:"/pages/order/order"
    })

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

    console.log("接受",options)
    this.data.payid = options.id
    console.log("qqq",this.data.payid)
    let lists  = wx.getStorageSync('goodsOrderList')
  let items =  lists.find((item)=>{
      return item.orderId == this.data.payid
    })


     // 获取时间
    var time = util.formatTime(new Date());
    this.setData({
      orderslists:items,
      times:time
    })

    


    // console.log("times:",this.data.times)

    // let obj = {"time":this.data.times}
    // console.log("ss",items)
    // console.log("obj",obj)
    // items.push(obj)



//     this.data.orderslists.orderLists.push(obj)
// console.log("对象",this.data.orderslists)

    // this.data.orderslists.forEach((item)=>{
    //   return item.orderLists
    // })

  
   
   

 
  
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {
    
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    // let lists = wx.getStorageSync('lists')
    // this.setData({
    //   orderslists:lists
    // })
    // console.log(this.data.orderslists)

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})